package com.caochenlei.flyweight;

import java.util.HashMap;

public class ChessPiecesFactory {
    private HashMap<String, ChessPieces> pools = new HashMap<>();

    public ChessPieces getChessPieces(String color) {
        if (!pools.containsKey(color)) {
            if ("白".equals(color)) {
                pools.put(color, new WhiteChessPieces());
            }
            if ("黑".equals(color)) {
                pools.put(color, new BlackChessPieces());
            }
        }
        return pools.get(color);
    }
}
